# -*- coding: utf-8 -*-
from flask import Flask
from .database import *

from config import UPLOAD_FOLDER

app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
from . import views

db.connect()
db.create_tables([Book, User, Record])
db.commit()
db.close()


@app.before_request
def before_request():
    db.connect()


@app.after_request
def after_request(response):
    db.close()
    return response
